﻿using MugenInjection.Interface;

namespace MugenInjection.Delegates
{
    /// <summary>
    ///     Represents the delegate to check the conditions in the <see cref="IBinding" />.
    /// </summary>
    /// <param name="bindingContext">
    ///     The specified <see cref="IBindingContext" />
    /// </param>
    /// <returns>The result of check.</returns>
    public delegate bool CanResolveBindingDelegate(IBindingContext bindingContext);

    /// <summary>
    ///     Represents the delegate to resolve instance for the specified <see cref="IScopeLifecycleContext" />.
    /// </summary>
    /// <param name="scopeLifecycleContext">
    ///     The specified <see cref="IScopeLifecycleContext" />.
    /// </param>
    /// <returns>An instance of the service.</returns>
    public delegate object CustomScopeDelegate(IScopeLifecycleContext scopeLifecycleContext);

    /// <summary>
    /// Represents the delegate to resolve instance for the specified <see cref="IBindingContext"/>.
    /// </summary>
    /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
    /// <returns>An instance of the service.</returns>
    public delegate object MethodBindingDelegate(IBindingContext bindingContext);

    /// <summary>
    /// Represents the delegate to resolve instance for the specified <see cref="IBindingContext"/>.
    /// </summary>
    /// <typeparam name="T">The specified object type.</typeparam>
    /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
    /// <returns>An instance of the service.</returns>
    public delegate T MethodBindingDelegate<out T>(IBindingContext bindingContext);

    /// <summary>
    /// Represents the delegate to build binding.
    /// </summary>
    /// <param name="bindingBuilder">The specified <see cref="IBindingBuilder"/>.</param>
    /// <returns>An instance of <see cref="IBindingBuilder"/>.</returns>
    public delegate IBindingBuilder BindingBuildingDelegate(IBindingBuilder bindingBuilder);

    /// <summary>
    /// Represents the delegate that invoked after build binding.
    /// </summary>
    /// <param name="bindingBuilder">The specified <see cref="IBindingBuilder"/>.</param>
    /// <returns>An instance of <see cref="IBinding"/>.</returns>
    public delegate IBinding BindingBuildedDelegate(IBindingBuilder bindingBuilder);

    /// <summary>
    /// Represents the delegate that invoked after binding activated.
    /// </summary>
    /// <typeparam name="T">The type of service.</typeparam>
    /// <param name="binding">The specified <see cref="IBinding"/>.</param>
    /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
    /// <param name="instance">The specified instance.</param>
    public delegate void BindingActivatedDelegate<T>(IBinding binding, IBindingContext bindingContext, ref T instance);
}